import {Component, EventEmitter, Input, Output} from '@angular/core';
import {
    ActionSheetController,
    AlertController, LoadingController, ModalController, NavController, NavParams,
    Platform, ToastController
} from 'ionic-angular';
import {PlanPage} from "../plan/plan";
import {ExpendPage} from "../expend/expend";
import {SystemService} from "../../service/SystemService";
import {UserManager} from "../../../framework/manager/UserManager";
import {BasePage} from "../../BasePage";
import {Log} from "../../../framework/utils/Log";
import {SLLocalStorageUtils} from "../../../framework/utils/SLLocalStorageUtils";
import {Camera, CameraOptions} from "@ionic-native/camera";
import {ImagePicker, ImagePickerOptions} from "@ionic-native/image-picker";
import {FeeApplyDom} from "../feeApplyDom/feeApplyDom";
import {ApplyInfoTabPage} from "../apply-info-tab/apply-info-tab";
import {ApplyListAPage} from "../applyList";
import {ApplyStoreSLS} from "../applyStoreSLS";

/**
 * Generated class for the ApplyTabPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@Component({
    selector: 'page-apply-tab',
    templateUrl: 'apply-tab.html',
    providers: [SystemService]
})
export class ApplyTabPage extends BasePage {
    private static TAG: string = 'ApplyTabPage';
    bxBranchLabel: string = '';//报销部门
    bxBranchId: string = '0';
    bxBranchList: any = [];
    bxTypeLabel: string = '';
    bxTypeId: number;
    sxAppleFee: string = '';
    zbName: string='';//指标名称
    expendName: string='';
    expendId: string;
    expendNewId:string='';

    availableMoney: string='';//可用金额
    branchId: string;//部门编号
    branchName: string;
    unitId: string;
    compactStageLabel: string = '';//合同阶段
    compactStageList: any = [];
    compactName: string = '';
    compactStageId: any;//合同阶段id
    year: string;
    userId: string;
    zbId: string;//指标编号
    zbNewId:string;
    htInfo: any = [];
    zxRequestInfo: any = [];
    zxApplyLabel: string = '';
    bxsyVal: string = "";//报销事由
    remarkVal: string = "";//备注
    applyMoney: string;//申请金额
    submitPerson: string='';//报销人
    bxApplyItem: string;
    applyPerson: string;//申请人
    applyDH: string;//申请单编号
    //applyMoneyID:string;//申请金额
    applyMoneyList: any = [];//资金申请单列表
    zbApplyName: string = "";//从报销申请单得到的指标名称
    applyDate: string='';
    @Input() editDetails: any;
    @Output() childEvent = new EventEmitter<any>();

    bxTypeList: any = [];
    private fileList: any = [];
    private fuJianList: any = [];
    private detailsInfo: any;
    private spType: any;
    private applyInfo: any;
    private assistInfo: any = [];
    private closeAccountInfo: any = [];
    private zhichuInfo: any = [];
    private DuiYingDJLX:string;
    private BiaoXiaoBH:string='';
    private editBool:boolean=false;
    private editInfo:any;
    private moneyAppleBool:boolean=false;
    private moneyAppleInfo:any;
    constructor(public navCtrl: NavController,
                public navParams: NavParams,
                private actionSheetCtrl: ActionSheetController,
                public camera: Camera,
                public imagePicker: ImagePicker,
                public modalCtrl: ModalController,
                public sys: SystemService,
                public platform: Platform,
                public loadingCtrl: LoadingController,
                public toastCtrl: ToastController,
                public alertCtrl: AlertController) {
        super(platform, loadingCtrl, toastCtrl, alertCtrl);
        this.branchId = UserManager.getInstance().user.branchId;
        this.year = UserManager.getInstance().user.year;
        this.userId = UserManager.getInstance().user.userId;
        this.unitId = UserManager.getInstance().user.unitId;
        this.applyPerson = UserManager.getInstance().user.userId;
        this.submitPerson = UserManager.getInstance().user.userName;
        this.detailsInfo = navParams.data.data;
        this.spType = navParams.data.type;
    }

    async ngOnInit() {
        this.getAppleType();
        this.applyDate = new Date(new Date().getTime() + 8 * 60 * 60 * 1000).toISOString();//申请时间
        if (this.spType == "4") {
            this.BiaoXiaoBH = this.navParams.data.data.DanJuBH;
            console.log("编辑时单据编号=====",this.BiaoXiaoBH);

            this.getCheckDetail(this.detailsInfo);
        }
    }
    ionViewWillEnter(){
        this.branchId = UserManager.getInstance().user.branchId;
        this.year=UserManager.getInstance().user.year;
    }

    getEditInfo() {
        this.editBool=true;
        if (this.applyInfo != undefined && null != this.applyInfo) {
            this.bxTypeLabel = this.applyInfo.BaoXiaoDLX;
            this.bxsyVal = this.applyInfo.BaoXiaoSY;
            this.zbName = this.applyInfo.ZhiBiaoMC;
            this.zbId = this.applyInfo.ZhiBiaoBH;
            this.zbNewId = this.applyInfo.ZhiBiaoBH;
            this.expendName = this.applyInfo.ZhiChuSX;
            this.expendId = this.applyInfo.ZhiChuSXBH;
            this.expendNewId = this.applyInfo.ZhiChuSXBH;
            this.availableMoney = this.applyInfo.KeYongYE;
            this.bxBranchLabel = this.applyInfo.BaoXiaoBM;
            this.bxBranchId = this.applyInfo.BaoXiaoBMBH;
            this.applyMoney = this.applyInfo.ShenQingJE;
            this.applyDate = this.applyInfo.ShenQingRQ;
            this.submitPerson = this.applyInfo.BaoXiaoR;
            this.compactStageLabel = this.applyInfo.HeTongJD;
            this.compactStageId = this.applyInfo.HeTongJDBH;
            this.fileList = this.applyInfo.DanJuFJ;

            this.getBranchId(this.bxTypeLabel);
        }
    }

    ionViewDidLoad() {
        //ApplyStoreSLS.getInstance().destroy();
        this.getRequestInfo();
        this.getContractInfo();
        this.getBranchListInfo();
        this.getApplyMoneyInfo();
    }
    async getCheckDetail(_d) {
        let data: any = {
            BianHao: _d.DanJuBH,
            LiuChengId: _d.LiuChengId,
            RenWuID: _d.RenWuID,
            DangQianJD: _d.DangQianJD
        };
        await this.sys.getCheckDetail(data).subscribe((res: any) => {
            Log.printObj(ApplyTabPage.TAG, 'ApplyInfo printObj==', res);
            if (res.msgCode == '1') {
                this.applyInfo = res.DanJuXX;
                this.assistInfo = res.FuZhuXX;
                this.closeAccountInfo = res.JieSuanXX;
                this.zhichuInfo = res.ZhiChuMX;
                this.editInfo = res;
                this.getEditInfo();
            } else {
                this.showError('数据请求失败');
            }

        }, error => {
            this.showError('数据请求失败');
        })
    }

    editApplyType(str) {

    }

    getAppleType() {
        this.sys.getBaoXiaoType().subscribe((res: any) => {
            Log.printObj(ApplyTabPage.TAG, "报销类型==", res);
            if (res.msgCode == "1") {
                this.bxTypeList = res.list;
                this.bxTypeList.forEach(v => {
                    if (v.ISDefault == 1) {
                        this.bxTypeLabel = v.MingCheng;
                        this.bxTypeId = v.BianHao;
                        //this.getBranchId(this.bxTypeLabel);
                    }
                })
            }
        }, err => {

        })
    }

    getBranchId(str) {
        if (str == '直接报销') {
            this.bxTypeId = 1;
        } else if (str == '资金申请报销') {
            this.zbApplyName = this.applyInfo.HeTongMC;
            this.bxTypeId = 2;
        } else if (str == '执行申请报销') {
            this.zxApplyLabel = '';
            this.bxTypeId = 3;
        } else if (str == '合同支付报销') {
            this.compactName = this.applyInfo.HeTongMC;
            this.compactStageLabel = this.applyInfo.HeTongJD;
            this.bxTypeId = 4;
        } else if (str == '全额还款') {
            this.bxTypeId = 5;
        }
        this.applyDH = this.applyInfo.ZhiXingSQD;
    }

    bxTypeHander() {
        let alert = this.alertCtrl.create();
        alert.setTitle('报销类型');
        this.bxTypeList.map((value) => {
            alert.addInput({
                type: 'radio',
                label: value.MingCheng,
                value: value.BianHao,
                checked: value.ISDefault == 1 ? true : false
            });
        });
        alert.addButton('取消');
        alert.addButton({
            text: '确定',
            handler: data => {
                this.zbApplyName = '';
                this.availableMoney = '';
                this.expendName ='';
                this.zbName = '';
                this.applyDH='';
                this.bxsyVal='';
                this.fileList.length=0;
                this.bxTypeId = data;
                this.moneyAppleBool=false;
                this.bxTypeList.map((value) => {
                    if (data == value.BianHao) {
                        this.bxTypeLabel = value.MingCheng;

                        value.ISDefault = 1;
                        if(this.bxTypeLabel=="资金申请报销"){
                            this.getApplyMoneyInfo();
                        }
                        if(this.bxTypeLabel=="执行申请报销"){
                            this.getRequestInfo();
                        }
                        if(this.bxTypeLabel=="合同支付报销"){
                            this.getContractInfo();
                        }
                    } else {
                        value.ISDefault = 0;
                    }
                });
            }
        });
        alert.present();
    }

    zbNameHander(item) {
        let profileModal = this.modalCtrl.create(PlanPage, {list: item, danJuBH: this.applyDH, bxType: this.bxTypeId});
        profileModal.onDidDismiss((item) => {
            if (item) {
                this.expendName ="";
                this.zbName = item.name;
                this.availableMoney = item.fee;
                this.zbId = item.zbid;
            }
        });
        profileModal.present();
    }
    resetApply(){
        this.availableMoney = '';
        this.expendName ='';
        this.zbName = '';
    }
    //获取部门列表
    getBranchListInfo() {
        //this.showLoading(true, '');
        let data: any = {
            BuMenBH: this.branchId
        };
        this.sys.getBranchList(data).subscribe((res: any) => {
            if (res.msgCode == '1' && res.list.length > 0) {
                this.bxBranchList = res.list;
                this.bxBranchId = res.list[0].BianHao;
                this.bxBranchLabel = res.list[0].MingCheng;
                //this.bxBranchHander(res.list);
            } else {
                this.showError('部门列表不存在');
            }
        }, error => {
            this.showError('数据获取失败');
        })
    }

    bxBranchHander() {
        let alert = this.alertCtrl.create();
        alert.setTitle('报销部门');
        this.bxBranchList.forEach((value, index) => {
            alert.addInput({
                type: 'radio',
                label: value.MingCheng,
                value: value.BianHao,
                checked: index == 0 ? true : false
            });
        });
        alert.addButton('取消');
        alert.addButton({
            text: '确定',
            handler: data => {
                this.bxBranchId = data;
                console.log(this.bxBranchId,"=====");
                this.bxBranchList.forEach((v, i) => {
                    if (data == v.BianHao) {
                        this.bxBranchLabel = v.MingCheng;
                    }
                });
            }
        });
        alert.present();
    }

    //获取指标
    getProject() {
        if (this.bxTypeLabel == '') {
            this.showError("请先选择报销类型");
            return;
        }
        if (this.zbApplyName == "" && this.bxTypeId != 1 && this.bxTypeLabel != '直接报销') {
            this.showError("请先选择" + this.bxTypeLabel);
            return;
        }
        //this.showLoading(true, '');
        let data: any = {
            BuMenBH: this.branchId,
            NianDu: this.year,
            YongHuBH: this.userId,
            ZhiBiaoMC: this.zbApplyName,
            DanJuBH: this.applyDH,
            BaoXiaoLX: this.bxTypeId
        };
        this.sys.getProject(data).subscribe((res: any) => {
            if (res.msgCode == '1') {
                if(res.list.length>0){
                    this.zbNameHander(res.list);
                }else {
                    this.showError('指标列表不存在')
                }
            } else {
                this.showError('指标列表获取失败')
            }
            // this.showLoading(false, '')

        }, error => {
            this.showError('数据获取失败');
            //this.showLoading(false, '')

        })
    }



    sxExpendHander(list) {
        let profileModal = this.modalCtrl.create(ExpendPage, {list: list});
        profileModal.onDidDismiss((item) => {
            if (item) {
                this.expendName = item.name;
                this.expendId = item.sxId;
                this.sxAppleFee = item.fee;
               // UserManager.getInstance().user.zcId = item.sxId;
            }
        });
        profileModal.present();
    }

    //获取支出事项
    getPayItems() {

        if (this.zbId == undefined) {
            this.showError('请先选择指标名称');
            this.showLoading(false, '');
            return;
        }
        let data: any = {
            ZhiBiaoBH: this.zbId
        };
        this.sys.getPayItems(data).subscribe((res: any) => {
            if (res.msgCode == '1') {
                if(res.list.length>0){
                    this.sxExpendHander(res.list);
                }else {
                    this.showError('支出事项不存在')
                }

            } else {
                this.showError('支出事项获取失败')
            }
        }, error => {
            this.showError('数据获取失败');
        })
    }


    /*
    * 执行申请单
    * */
    getRequestInfo() {
        let data: any = {
            BuMenBH: this.branchId,
            YongHuBH: this.userId,
            YuSuanND: this.year
        };
        this.sys.getRequestInfo(data).subscribe((res: any) => {
            if (res.msgCode == '1' && res.list.length > 0) {
                this.zxRequestInfo = res.list;
            } else {
                //this.showToast('无可用的执行申请单');
            }
        }, error => {
            this.showError('数据获取失败');

        })
    }

    zxApplyListInfo() {
        if (this.zxRequestInfo.length == 0) {
            this.showError("没有可用的执行申请列表");
            return;
        }
        let alert = this.alertCtrl.create();
        alert.setTitle('执行申请单');
        this.zxRequestInfo.forEach((value, index) => {
            alert.addInput({
                type: 'radio',
                label: value.BiaoTi,
                value: value.BianHao,
                checked: this.zxApplyLabel == value.BiaoTi? true : false
            });
        });
        alert.addButton('取消');
        alert.addButton({
            text: '确定',
            handler: data => {
                this.resetApply();
                this.applyDH = data;
                this.zxRequestInfo.forEach((v, i) => {
                    if (data == v.BianHao) {
                        this.zbApplyName = v.ZhiBiaoMC;
                        this.zxApplyLabel = v.BiaoTi;
                        this.BiaoXiaoBH =v.BianHao;

                    }
                });
            }
        });
        alert.present();
    }

    //获取资金申请单信息
    getApplyMoneyInfo() {
        let data: any = {
            BuMenBH: this.branchId,
            YongHuBH: this.userId,
            YuSuanND: this.year
        };
        this.sys.getApplyMoneyInfo(data).subscribe((res: any) => {
            if (res.msgCode == '1' && res.list.length > 0) {

                //this.applyMoneyLabel =res.ZhiBiaoMC;
                this.applyMoneyList = res.list;
                Log.printObj(ApplyTabPage.TAG, 'result==', res);
            } else {
                //this.showToast('无可用的资金执行申请单');
            }
        }, error => {
            this.showToast('资金执行申请单获取失败');

        })
    }

    getFeeApplyListInfo() {
        if (this.applyMoneyList.length == 0) {
            this.showError("没有可用的资金申请列表");
            return;
        }
        let profileModal = this.modalCtrl.create(FeeApplyDom, {list: this.applyMoneyList});
        profileModal.onDidDismiss((item) => {
            this.resetApply();
            if (item) {
                this.applyMoney='';
                ApplyStoreSLS.getInstance().destroy();//选择资金申请单时销毁已填写的数据
                Log.printObj(ApplyTabPage.TAG,'资金申请单信息====',item);
                this.moneyAppleBool=true;
                this.moneyAppleInfo =item;
                this.applyDH = item.data.BianHao;
                this.zbApplyName = item.data.ZhiBiaoMC;
                this.zbName = item.data.ZhiBiaoMC;
                this.zbId= item.data.ZhiBiaoBH;
                this.expendName= item.data.ZCSXMingCheng;
                this.expendId = item.data.ZCSXBianHao;
                this.bxsyVal =item.data.BaoXiaoSY;
                this.sxAppleFee=item.data.FeiYongXE;
                this.DuiYingDJLX = item.data.DuiYingDJLX;
                this.availableMoney =item.data.ZiJinSQJE;
                this.BiaoXiaoBH =item.data.BianHao;
            }
        });
        profileModal.present();
    }

    /*
   * 获取合同信息
   * */
    getContractInfo() {
        let data: any = {
            BuMenBH: this.branchId,
            YongHuBH: this.userId,
            YuSuanND: this.year
        };
        this.sys.getContractInfo(data).subscribe((res: any) => {
            if (res.msgCode == "1" && res.list.length > 0) {
                this.htInfo = res.list;
                if (this.compactStageLabel != "") {
                    this.htInfo.map(v => {
                        v.HeTongJD.map(v1 => {
                            if (v1.HeTongJD == this.compactStageLabel) {
                                this.compactStageList = v.HeTongJD;
                                this.compactStageId =v.JieDuanBH;
                                console.log('阶段编号：',this.compactStageId)
                            }
                        })
                    })
                }

                //this.compactList();
            } else {
                //this.showToast('无可报销的合同信息');
            }
        }, error => {
            this.showError('数据获取失败');

        })
    }

    compactList() {
        let alert = this.alertCtrl.create();
        alert.setTitle('合同名称');
        this.htInfo.forEach((value, index) => {
            alert.addInput({
                type: 'radio',
                label: value.HeTongMC,
                value: value.BianHao,
                checked: this.compactName  == value.HeTongMC ? true : false
            });
        });
        alert.addButton('取消');
        alert.addButton({
            text: '确定',
            handler: data => {
                this.resetApply();
                this.applyDH = data;
                this.htInfo.forEach((v, i) => {
                    if (data == v.BianHao) {
                        // this.bxBranchLabel = v.MingCheng;
                        this.zbApplyName = v.ZhiBiaoMC;
                        this.compactName = v.HeTongMC;
                        this.compactStageList = v.HeTongJD;
                        this.compactStageLabel ='';
                        this.BiaoXiaoBH=v.BianHao;
                        if (this.compactStageList.length == 1) {
                            this.compactStageLabel = this.compactStageList[0].HeTongJD;
                            this.compactStageId = this.compactStageList[0].JieDuanBH;
                        }

                    }
                });
            }
        });
        alert.present();
    }

    compactStageListInfo() {
        let alert = this.alertCtrl.create();
        alert.setTitle('合同阶段');
        this.compactStageList.forEach((value, index) => {
            alert.addInput({
                type: 'radio',
                label: value.HeTongJD,
                value: value.JieDuanBH,
                checked: this.compactStageLabel == value.HeTongJD ? true : false
            });
        });
        alert.addButton('取消');
        alert.addButton({
            text: '确定',
            handler: data => {
                this.compactStageId = data;
                console.log('阶段编号：',this.compactStageId);
                this.compactStageList.forEach((v, i) => {
                    if (data == v.JieDuanBH) {
                        if(v.IsUse ==='false'){
                            this.showError("前一阶段的报销未完成，请先进行前一阶段的报销")
                        }else {
                            this.compactStageLabel = v.HeTongJD;
                        }
                    }
                });
            }
        });
        alert.present();
    }


    presentActionSheet() {
        let actionSheet = this.actionSheetCtrl.create({
            buttons: [{
                text: '拍照',
                role: 'takePhoto',
                handler: () => {
                    this.takePhoto();
                }
            }, {
                text: '从相册选择',
                role: 'chooseFromAlbum',
                handler: () => {
                    this.chooseFromAlbum();
                }
            }, {
                text: '取消',
                role: 'cancel',
                handler: () => {
                }
            }]
        });

        actionSheet.present().then(value => {
            return value;
        });
    }

    takePhoto() {
        const options: CameraOptions = {
            targetWidth: 800,
            targetHeight: 800,
            saveToPhotoAlbum: true,
            quality: 50,//图片的质量0-100之间选择
            sourceType: this.camera.PictureSourceType.CAMERA,
            destinationType: this.camera.DestinationType.DATA_URL,
        };

        this.camera.getPicture(options).then(image => {
            //this.fuJianList.splice(0,this.fuJianList.length);
            // Log.printObj(ApprovePage.TAG, '相机拍照Image URI:== ', image);
            if (image != undefined || null != image) {
                this.fuJianList.push({value: "data:image/jpeg;base64," + image});
                this.updateImgServer(this.fuJianList);
            }
        }, error => {
            Log.printObj(ApplyTabPage.TAG, '相机拍照ImageError:== ', error);
        });
    }

    chooseFromAlbum() {
        this.imagePicker.hasReadPermission().then(result => {
            if (result) {
                this.chooseImg();
            } else {
                this.showToast('没有权限访问你的相册');
            }
        });
    }

    chooseImg() {
        //this.fuJianList.splice(1,this.fuJianList.length);
        const options = {
            maximumImagesCount: 5,
            width: 800,
            height: 800,
            outputType: 1,
            quality: 40
        };
        this.imagePicker.getPictures(options).then(DATA_URL => {
            if (DATA_URL.length > 5) {
                this.presentAlert();
            } else if (DATA_URL.length <= 5) {
                for (let i = 0; i < DATA_URL.length; i++) {
                    //this.fileList.push( DATA_URL[i]);
                    this.fuJianList.push({value: "data:image/jpeg;base64," + DATA_URL[i]});
                }
                this.updateImgServer(this.fuJianList);
            }
        }, error => {
            Log.printObj(ApplyTabPage.TAG, '选择相册图片ImageError:== ', error);

        });
    }

    presentAlert() {
        let alert = this.alertCtrl.create({title: "上传失败", message: "最多选择5张图片", buttons: ["确定"]});
        alert.present().then(value => {
            return value;
        });
    }

    updateImgServer(data) {
        this.sys.getFileUpload(data).subscribe(async (res: any) => {
            Log.printObj(ApplyTabPage.TAG, "上传附件接口result==", res);
            if (res.msgCode == "1" && res.list.length > 0) {
                this.fileList = res.list;
                try {
                    await SLLocalStorageUtils.getInstance().setFileInfo(this.fileList);
                } catch (error) {
                    Log.printObj(ApplyTabPage.TAG, "error == ", error);
                    throw error;
                }
                this.showToast("上传成功");
            } else {
                //this.showError("上传失败");
            }
        }, error => {
            this.showError("上传失败");
            Log.printObj(ApplyTabPage.TAG, "上传附件接口 error result==", error);

        })
    }

    /**
     * 计算输入的字数
     */
    private countWords() {
        if (this.bxsyVal.length > 500) {
            this.showToast("最多可以输入500个字");
            // this.mInputWords = this.mTextArea.value.length;
        }

    }
    private isShowBool:boolean=false;
    private isRemarkValBool: boolean=false;
    onTextKeyDown(type) {
        if (type == "1") {
            if(this.strlen(this.bxsyVal)>=500){
               // this.bxsyValLen=this.strlen(this.bxsyVal);
                if(!this.isShowBool){
                    this.isShowBool=true;
                    this.showToast("最多可以输入500个字符");
                    setTimeout(()=>{
                        this.isShowBool=false;
                    },5000)
                }

            }
        } else {
            if(this.strlen(this.remarkVal)>=2000){
                //this.remarkValLen=this.strlen(this.remarkVal);
                if(!this.isRemarkValBool){
                    this.isRemarkValBool=true;
                    this.showToast("最多可以输入2000个字符");
                    setTimeout(()=>{
                        this.isRemarkValBool=false;
                    },5000)
                }

            }
        }

    }

    onTextKeyUp(type) {

    }
    //判断字符是单字节还是双字节
    strlen(str) {
        var len = 0;
        for (var i = 0; i < str.length; i++) {
            var c = str.charCodeAt(i);
            //单字节加1
            if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
                len++;
            }
            else {
                len += 2;
            }
        }
        return len;
    }
    ionViewDidLeave(){
    }
    async next() {

        if(this.expendNewId == this.expendId && this.zbNewId == this.zbId){
           // this.editBool = true;
        }else {
            //this.editBool = false;
        }
        // console.log('合同阶段：',this.compactStageId)
        if (this.bxTypeLabel != '' && this.zbName != '' && this.availableMoney != '' && this.bxBranchLabel != '' && this.submitPerson != ''
            && this.bxsyVal != '' && this.expendName != '' && this.applyDate != '' ) {
            let data: any = {
                BiaoXiaoBH: this.BiaoXiaoBH,
                BaoXiaoLX: this.bxTypeId,
                ZhiBiaoBH: this.zbId,
                ShenQingR: this.applyPerson,
                NianDu: this.year,
                ShenQingDW: this.unitId,
                ShenQingBM: this.branchId,
                ShenQingJE: this.applyMoney,
                BaoXiaoR: this.submitPerson,
                BaoXiaoBM: this.bxBranchId,
                BaoXiaoRQ: this.applyDate,
                BaoXiaoSY: this.bxsyVal,
                ZhiChuSX: this.expendId,
                BeiZhu: this.remarkVal,
                DuiYingDJ: this.applyDH,
                KeYongYE: this.availableMoney,
                HeTongJD: this.compactStageId
            };

            try {
                await SLLocalStorageUtils.getInstance().setAppleFee(this.applyMoney);
                await SLLocalStorageUtils.getInstance().setApply(data);
                await SLLocalStorageUtils.getInstance().setZbFee(this.availableMoney);
                await SLLocalStorageUtils.getInstance().setAppleSXFee(this.sxAppleFee);

                this.navCtrl.push(ApplyInfoTabPage,{sxId:this.expendId,danJuBH: this.BiaoXiaoBH,bxType:this.spType,editBool:this.editBool,editInfo:this.editInfo,moneyAppleBool:this.moneyAppleBool,moneyAppleInfo:this.moneyAppleInfo});
                //this.childEvent.emit({'name': '支出信息', 'id': 1});
            } catch (error) {
                Log.printObj(ApplyTabPage.TAG, "error == ", error);
                throw error;
            }
        } else {
            this.showError('填写的信息不完整');
        }
    }
}
